<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.util.ToPinyin"%>
<%@page import="crm.control.EmployeesControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>employees_update_do</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			int id = Integer.parseInt(request.getParameter("id"));
			//System.out.println("id");
            Employees cu=(Employees)session.getAttribute("user");
			Employees employees = new Employees();
			employees = EmployeesControl.getEmpolyeesById(id);
			String name = ParamUtil.getString(request, "name");
			String namepy = ToPinyin.getPinYin(name);
			//System.out.println(namepy);

			employees.setArea_id(ParamUtil.getInt(request, "area_id"));
			employees.setBaby_birth(ParamUtil.getString(request, "baby_birth"));
			employees.setBirthday(ParamUtil.getString(request, "birthday"));
			employees.setCellphone(ParamUtil.getString(request, "cellphone"));
			employees.setEdu_level(ParamUtil.getString(request, "edu_level"));
			employees.setEmail(ParamUtil.getString(request, "email"));
			employees.setFamily_address(ParamUtil.getString(request,"family_address"));
			employees.setGender(ParamUtil.getString(request, "gender"));
			employees.setHome_type(ParamUtil.getString(request, "home_type"));
			employees.setIdcard(ParamUtil.getString(request, "idcard", ""));
			employees.setIs_married(ParamUtil.getString(request, "is_married"));
			employees.setName(ParamUtil.getString(request, "name"));
			employees.setNamepy(namepy);
			employees.setNation(ParamUtil.getInt(request, "nation"));
			employees.setPhone(ParamUtil.getString(request, "phone"));
			employees.setPolity(ParamUtil.getInt(request, "polity"));
			employees.setUsername(ParamUtil.getString(request, "username"));
			
			employees.setPassword(ParamUtil.getString(request, "password"));
			if(cu.getPosition()!=1){
			employees.setPosition(ParamUtil.getInt(request, "position"));
			}
			employees.setStart_time(ParamUtil.getString(request, "start_time"));
			employees.setNamepy(ParamUtil.getString(request, "namepy"));

			if (EmployeesControl.updateEmployees(employees)) {
		%>
		<script type="text/javascript">
if (window.confirm("修改成功！"))
	window.top.location.href = "../recepit/show_all_recepits.jsp";
else
	window.top.location.href = "employees.jsp";
</script>
		<%
			} else {
		%>
		<script type="text/javascript">
if (window.confirm("修改失败！"))
	window.location.href = "employees_update.jsp";
else
	window.location.href = "employees_update.jsp";
</script>
		<%
			}
		%>
	</body>
</html>